import { defineConfig } from 'vitepress'
import { chineseSearchOptimize, pagefindPlugin } from 'vitepress-plugin-pagefind'

export default defineConfig({
  title: "未青全站编程",
  description: "一个热爱生活的程序员",
  lang: 'zh-cn',
  vite: {
    plugins: [pagefindPlugin({
      btnPlaceholder: '搜索',
      placeholder: '搜索文档',
      emptyText: '空空如也',
      heading: '共: {{searchResult}} 条结果',
      excludeSelector:['img','a.header-anchor'],
      customSearchQuery(input){
        // 将搜索的每个中文单字两侧加上空格
        return input.replace(/[\u4e00-\u9fa5]/g, ' $& ')
        .replace(/\s+/g,' ')
        .trim();
      },
      resultOptimization: false,
  filter(searchItem, idx, originArray) {
    console.log(searchItem);
    return !searchItem.route.includes('404') 
  }
    })],
  },
  lastUpdated: true,
  themeConfig: {
    logo: "apple2.png",
    nav: [
      { text: '首页', link: '/' },
      { 
        text: '作品集', items:[
          {text:"作品集",link: '/document/works/index'},
          {text:"和风天气小程序",link: '/document/works/wxsky/01.dome'},
          {text:"课表小程序",link: '/document/works/wxclass/'}
        ]
       },
      { text: '前端', link: '/document/frontend/' },
      { text: '后端', link: '/document/backend/' },
      { 
        text: '技术栈', items:[
          {text:"Flex布局",link: 'https://www.runoob.com/w3cnote/flex-grammar.html'},
          {text:"VUE3文档",link: 'https://cn.vuejs.org/guide/introduction.html'},
          {text:"课表小程序",link: '/document/works/wxclass/'}
        ]
       },
    ],

    sidebar: {
      // 当用户位于 `guide` 目录时，会显示此侧边栏
      '/document/works/wxsky/': [
        {
          text: '和风天气小程序',
          collapsed: false,
          items: [
            { text: '准备', link: '/document/works/wxsky/01.dome' },
            { text: '代码编写', link: '/document/works/wxsky/02.dome' },
          ]
        }
      ],
      '/document/works/wxclass/': [
        {
          text: '课表小程序',
          collapsed: false,
          items: [
            { text: '准备', link: '/document/works/wxclass/01.dome' },
          ]
        }
      ],
    },

    socialLinks: [
      {
        icon: {
          svg: '<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1711713061928" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="5060" xmlns:xlink="http://www.w3.org/1999/xlink" width="48" height="48"><path d="M512 1024C229.222 1024 0 794.778 0 512S229.222 0 512 0s512 229.222 512 512-229.222 512-512 512z m259.149-568.883h-290.74a25.293 25.293 0 0 0-25.292 25.293l-0.026 63.206c0 13.952 11.315 25.293 25.267 25.293h177.024c13.978 0 25.293 11.315 25.293 25.267v12.646a75.853 75.853 0 0 1-75.853 75.853h-240.23a25.293 25.293 0 0 1-25.267-25.293V417.203a75.853 75.853 0 0 1 75.827-75.853h353.946a25.293 25.293 0 0 0 25.267-25.292l0.077-63.207a25.293 25.293 0 0 0-25.268-25.293H417.152a189.62 189.62 0 0 0-189.62 189.645V771.15c0 13.977 11.316 25.293 25.294 25.293h372.94a170.65 170.65 0 0 0 170.65-170.65V480.384a25.293 25.293 0 0 0-25.293-25.267z" fill="#C71D23" p-id="5061"></path></svg>'
        },
        link: 'https://gitee.com/JMweiqing',
        // 也可以为无障碍添加一个自定义标签 (可选但推荐):
        ariaLabel: 'gitee'
      }
    ],
    // 底部说明
    footer:{
      copyright:"Copyright@ 2024 Albert WQ"
    }
  }
})

